package com.toidep.base;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;

import com.slidingmenu.lib.SlidingMenu;
import com.slidingmenu.lib.app.SlidingFragmentActivity;
import com.toidep.R;
import com.toidep.config.ConfigUtility;
import com.toidep.fragment.mains.MenuFragment;

public class BaseABSActivity extends SlidingFragmentActivity {

	private ProgressDialog progressDialog;
	
	public MenuFragment menuFragment;
	protected SlidingMenu slidingMenu;
	

	@Override
	public void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);

		// set the Behind View
		setBehindContentView(R.layout.menu_frame);
		FragmentTransaction t = this.getSupportFragmentManager().beginTransaction();
		menuFragment = new MenuFragment();
		t.replace(R.id.menu_frame, menuFragment);
		t.commit();

		// customize the SlidingMenu
		slidingMenu = getSlidingMenu();
		
		slidingMenu.setShadowWidthRes(R.dimen.shadow_width);
		slidingMenu.setShadowDrawable(R.drawable.shadow);
		slidingMenu.setBehindOffset((int)((ConfigUtility.scrWidth *1f) / (5)));
		slidingMenu.setFadeDegree(0.35f);
		slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
		
	}

	// Show/hide Progress Dialog
	public void showProgressDialog() {
		if (progressDialog == null) {
			progressDialog = ProgressDialog.show(this, null, getResources().getString(R.string.text_processing), true);
			progressDialog.setCancelable(false);
		}
	}

	public void closeProgressDialog() {
		if (progressDialog != null) {
			progressDialog.cancel();
			progressDialog = null;
		}
	}
	
}
